package cz.cvut.fel.gfupan.gui.action;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.util.Random;
import javax.swing.JComponent;
import javax.swing.JFileChooser;
import javax.swing.text.JTextComponent;

public class LoadFAction implements ActionListener {

    private JComponent panel;
    private JTextComponent box;
    private JFileChooser fc;

    public LoadFAction(JComponent panel, JTextComponent box) {
        this.box = box;
        this.panel = panel;
        fc = new JFileChooser();
    }

    @Override
    public void actionPerformed(ActionEvent ae) {
        int returnVal = fc.showOpenDialog(panel);

        if (returnVal == JFileChooser.APPROVE_OPTION) {
            File file = fc.getSelectedFile();

            if (file != null && box != null) {
                box.setText(Integer.toString(new Random().nextInt()));
            }
        } else {
        }

//        Session.getInstance().setFdata(id, 0);

    }
}
